home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / tip / part-cr.tip < prev    next >
Text File  |  1993-09-15  |  3KB  |  95 lines

  1. % This macro source file is from the four volume series
  2. % "TeX in Practice" by Stephan von Bechtolsheim, published
  3. % 1993 by Springer-Verlag, New York.
  4. % Copyright 1993 Stephan von Bechtolsheim.
  5. % No warranty or liability is assumed.
  6. % This macro may be copied freely if no fees other than
  7. % media cost or shipping charges are charged and as long
  8. % as this copyright and the following source code itself
  9. % is not changed. Please see the series for further information.
  10. %
  11. % Version: 1.0
  12. % Date: May 1, 1993
  13. %
  14. %
  15. % This source code is documented in 30.8.1, p. III-564.
  16. % Original source in file "pp1.TEX", starting line 1572.
  17. \wlog{L: "part-cr.tip" ["pp1.TEX," l. 1572, p. III-564]}%
  18. % This file DOES belong to format "texip."
  19. \InputD{gobble.tip}
  20. \InputD{pickfs.tip}
  21. \InputD{namedef.tip}
  22. \InputD{defauarg.tip}
  23. \InputD{compst.tip}
  24. \InputD{isprefix.tip}
  25. \InputD{droppre.tip}
  26. \catcode`\@ = 11
  27. \newif\if@LabelsOk
  28. \def\@LabelRefPrefix{@REF-}
  29. \def\@LabelIsDefined #1{%
  30.     TT\fi
  31.     \if\NameDefinedConditional{\@LabelRefPrefix#1}%
  32. }
  33. \def\@NewLabel #1#2#3{% 
  34.     \if\@LabelIsDefined{#1}%
  35.         \wlog{\string\@NewLabel: warning: label "#1"
  36.             already defined.}%
  37.     \fi
  38.     \NameGdef{\@LabelRefPrefix #1}{{#2}{#3}}% 
  39. }
  40. \let\Saved@NewLabel = \@NewLabel
  41. \def\Ref #1{% 
  42.     \@ref{0}{#1}%
  43.     \if\StringsEqualConditional{\@TheExpandedLabel}{??}%
  44.         {??}%
  45.     \else
  46.         \@TheExpandedLabel
  47.     \fi
  48.     \@PrintAfterLabel
  49. }
  50. \def\PageRef #1{% 
  51.     \@ref{1}{#1}%
  52.     \if\StringsEqualConditional{\@TheExpandedLabel}{??}%
  53.         {??}%
  54.     \else
  55.         \@TheExpandedLabel
  56.     \fi
  57.     \@PrintAfterLabel
  58. }
  59. \def\@MostRecentLabel{}
  60. \def\@ref #1#2{%
  61.     \xdef\@PrintAfterLabel{}%
  62.     \DefaultArg{\@ThisLabel}{#2}{\@MostRecentLabel}% 
  63.     \if\StringsEqualConditional{\@ThisLabel}{.}% 
  64.         \xdef\@ThisLabel{\@MostRecentLabel}%
  65.         \xdef\@PrintAfterLabel{.}%
  66.     \fi
  67.     \if\StringsEqualConditional{\@ThisLabel}{,}% 
  68.         \xdef\@ThisLabel{\@MostRecentLabel}%
  69.         \xdef\@PrintAfterLabel{,}%
  70.     \fi
  71.     \if\StringsEqualConditional{\@ThisLabel}{)}% 
  72.         \xdef\@ThisLabel{\@MostRecentLabel}%
  73.         \xdef\@PrintAfterLabel{)}%
  74.     \fi
  75.     \if\StringsEqualConditional{\@ThisLabel}{;}%
  76.         \xdef\@ThisLabel{\@MostRecentLabel}%
  77.         \xdef\@PrintAfterLabel{;}%
  78.     \fi
  79.     \xdef\@MostRecentLabel{\@ThisLabel}% 
  80.     \if\@LabelIsDefined{\@ThisLabel}%
  81.         \edef\@CrefTemp{\NameUse{\@LabelRefPrefix\@ThisLabel}}%
  82.         \ifcase #1\relax 
  83.             \edef\@TheExpandedLabel{%
  84.                 \expandafter\PickFirstOfTwo\@CrefTemp}%
  85.         \or
  86.             \edef\@TheExpandedLabel{%
  87.                 \expandafter\PickSecondOfTwo\@CrefTemp}%
  88.         \fi
  89.     \else
  90.         \def\@TheExpandedLabel{??}
  91.         \wlog{\string\@ref: Label \@ThisLabel\space undefined.}%
  92.     \fi
  93. }
  94. \catcode`\@ = 12
  95.